<?php
//================ FORMS ===================
$MDOR = 'RD';
$OBJCTCL = 0;
if (!isset($_POST['CID'])) {
    $EXECMODE = 'SIMM';
    $_POST['CID'] = 0;
    $_POST['RID'] = 0;
    $_POST['AID'] = 0;
    $_POST['BnfPais'] = 76;
}

if (!isset($OBJCTOR)) {
    $MDOR = 'ED';
    $Order[0] = 1;
    $OBJCTOR = 0;
    $_POST['FraCalc'] = '0.00';
    $_POST['TmpOp'] = rand(1000000, 9999999);
    $ORVARS = $GLOBALS['MYT']->db_array("DESCRIBE Facturas");
    for ($v = 1; $v <= $ORVARS[0]; $v++) {
        $ORVAR = $ORVARS[$v]['Field'];
        $Order[1][$ORVAR] = '';
    }
} else {
    $Order = $GLOBALS['MYT']->db_array("SELECT * FROM Facturas WHERE FraID = {$OBJCTOR}");
    $_POST['TmpOp'] = $OBJCTOR;
    $_POST['FraCalc'] = number_format($Order[1]['FraEnviado'], 2);
}
if (!isset($_POST['OBJCTRC']) && isset($OBJCTRC)) {
    $_POST['OBJCTRC'] = $OBJCTRC;
} elseif (!isset($OBJCTRC)) {
    $_POST['OBJCTRC'] = $Order[1]['FraBnfNumero'];
}
if (!isset($ORTYPEPAY)) {
    $ORTYPEPAY = $Order[1]['FraModoPago'];
}
if (!isset($_POST['FraUrgente'])) {
    $_POST['FraUrgente'] = 0;
}
if (!isset($_POST['RTQuot'])) {
    $_POST['RTQuot'] = 0;
}
if (!isset($_POST['FraOrigen1'])) {
    $_POST['FraOrigen1'] = $_SESSION[$SESSCD];
}
if (!isset($_POST['FraMonCobro'])) {
    $_POST['FraMonCobro'] = 1;
}
if (!isset($_POST['FraMonDPagoISO'])) {
    $_POST['FraMonDPagoISO'] = 'BRL';
}

if (!isset($_POST['FraConcepto']) && $MDOR == 'ED') {
    $_POST['FraConcepto'] = 1;
} elseif (!isset($_POST['FraConcepto'])) {
    $_POST['FraConcepto'] = null;
}
//=====================Invoice Form=========================
form_pr('InvoiceProperties', '','', 'post');
// AML VARS
mn_field('hidden', 'ED', 'AMLCHECK', 'false', '', '', '', '');
mn_field('hidden', 'ED', 'AMLTYPE', '', '', '', '', '');
mn_field('hidden', 'ED', 'AMLDOCREQ', '', '', '', '', '');
mn_field('hidden', 'ED', 'AMLLEVEL', '', '', '', '', '');
mn_field('hidden', 'ED', 'AMLDESCR', '', '', '', '', '');
mn_field('hidden', 'ED', 'AML_alert', '', '', '', '', '');

mn_field('hidden', 'ED', 'OBJCTOR', $OBJCTOR, '', '', '', '');
mn_field('hidden', 'ED', 'OBJCTCL', $_POST['CID'], '', '', '', '');
mn_field('hidden', 'ED', 'OBJCTRC', $_POST['RID'], '', '', '', '');
mn_field('hidden', 'ED', 'OBJCTAC', $_POST['AID'], '', '', '', '');
mn_field('hidden', 'ED', 'TmpOp', $_POST['TmpOp'], '', '', '', '');
mn_field('hidden', 'ED', 'htr_ID', '', '', '', '', '');
mn_field('hidden', 'ED', 'FraCorresponsal', '', '', '', '', '');
mn_field('hidden', 'ED', 'FraConcepto', $_POST['FraConcepto'], '', '', '', ''); ?>
<table width="100%"  border="0" cellspacing="1" cellpadding="1">
    <tr>
        <td colspan="2">
            <table width="100%"  border="0" cellpadding="2" cellspacing="1">
                <tr bgcolor="#C5D8D8">
                    <td>Pais de Destino </td>
                    <td><strong>Recebido</strong></td>
                    <td width="55%" bgcolor="#C5D8D8"><strong>Taxa</strong></td>
                    <td><div align="center">Simulação</div></td>
                </tr>
                <tr bgcolor="#8AB0B0">
                    <td><?php
                        $Qur = "SELECT pai_CodElite AS ID, pai_NombreUSD AS NAME FROM hd_paises WHERE pai_ActivoGiros = 1";
                        mn_field('select', 'ED', 'BnfPais', '', $Qur, '', '', '');
?></td>
                    <td><?php
                        echo '<table><tr><td>';
                        $GETCUR = "SELECT mc_ID AS ID, mc_MonedaISO AS NAME FROM hd_monedascobro WHERE mc_Flag = 1";
                        mn_field('select', $MDOR, 'FraCalcISO', $Order[1]['FraMonCobro'], $GETCUR, '', 'False', '" readonly=""');
                        echo '</td><td>';
                        mn_field('text', $MDOR, 'FraCalc', $_POST['FraCalc'], '19', '12', 'False', 'INPNUM"');
                        echo '</td></tr></table>';
?></td>
                    <td><div id="ORTax"><?php include('remittancefee.php'); ?></div></td>
                    <td align="center"><div id="inv_Calc"><?php include($MODPAD . 'sim_clc.mex'); ?></div></td>
                </tr>
            </table></td>
    </tr>
    <tr>
        <td colspan="6">
            <div id="inv_Prom" class="Line"><?php //include('remittancepromotion.php'); ?></div>
            <div id="inv_Result" class="Line"></div></td>
    </tr>
    <tr>
        <td><table width="100%"  border="0" cellpadding="3" cellspacing="0" bgcolor="#F0F0EC">
                <tr>
                    <td>Tarifa: </td>
                    <td><?php
                        $QUOTAGE = "SELECT ntr_ID AS ID, ntr_Tarifa AS NAME
	 			FROM hd_tarifas
				INNER JOIN hd_tarifasgroups ON hd_tarifas.ntr_ID = hd_tarifasgroups.QUOTAGE
	 			WHERE OFFICE = {$_SESSION[$SESSOF]}
				AND qtSTATUS = 1
				AND qtDEFAULT = 1";
                        mn_field('select', $MDOR, 'RTQuot', $_POST['RTQuot'], $QUOTAGE, '', 'False', '" readonly=""
	 onChange="document.InvoiceProperties.action=\'_response/call.php?get=Operative/remittancerate\';
	 subform(\'InvoiceProperties\',\'ORRate\');
	 document.InvoiceProperties.action=\'_response/call.php?get=Operative/remittancefee.php\';
	 subform(\'InvoiceProperties\',\'ORTax\');');
?></td>
                </tr>
                <tr>
                    <td>Origem:</td>
                    <td><?php
                        $SUBDOMAIN = "SELECT OriNumero AS ID, OriNombre AS NAME FROM origenes
				WHERE OriDominio = (SELECT OriDominio FROM origenes
					WHERE OriActivo = 1 AND OriNumero = {$_SESSION[$SESSCD]}
					AND (OriDominio != 100 AND OriDominio != OriNumero))
				OR OriNumero = {$_SESSION[$SESSCD]}
				AND OriActivo = 1";
                        mn_field('select', $MDOR, 'FraOrigen1', $Order[1]['FraOrigen1'], $SUBDOMAIN, '', '', ''); ?></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </table></td>
        <td><table width="100%"  border="0" cellpadding="3" cellspacing="0" bgcolor="#CED9D9">
                <tr>
                    <td>Enviado:            </td>
                    <td><?php
                        mn_field('select', $MDOR, 'FraMonCobro', '', $GETCUR, '', 'False', '" readonly="');
                        mn_field('text', $MDOR, 'FraEnviado', '', '19', '15', 'False', 'INPNUM" readonly="'); ?></td>
                    <td>Recebido:            </td>
                    <td><?php
                        mn_field('select', $MDOR, 'FraEntregueISO', '', $GETCUR, '', 'False', '" readonly="');
                        mn_field('text', $MDOR, 'FraEntregue', '', '19', '15', 'False', 'INPNUM" readonly="');
?></td>
                </tr>
                <tr>
                    <td>A Pagar:            </td>
                    <td><?php
                        $GETCUR = "SELECT  miso_Cod_elite AS ID, miso_ID AS NAME FROM hd_monedasiso
		INNER JOIN hd_paises ON pai_MonedaBDE = miso_ID
		WHERE pai_CodElite = {$_POST['BnfPais']}";
                        mn_field('select', $MDOR, 'FraMonDPago', '', $GETCUR, '', 'False', '" readonly="');
                        mn_field('text', $MDOR, 'FraARecibir', '', '19', '15', 'False', 'INPNUM" readonly="'); ?></td>
                    <td>C&acirc;mbio:            </td>
                    <td><?php
                        mn_field('text', $MDOR, 'FraTasa', '', '6', '4', 'False', 'INPNUM" readonly="');
                        mn_field('hidden', $MDOR, 'FraTasaAgn', '', '6', '4', 'False', 'INPNUM" readonly="');
?></td>
                </tr>
                <tr>
                    <td>Tipo: </td>
                    <td><?php
                        $TransferTypes = "SELECT REF AS ID, Name AS NAME FROM hd_transfertypes";
                        mn_field('select', $MDOR, 'FraUrgente', $_POST['FraUrgente'], $TransferTypes, '', 'False', '"
		onChange="document.InvoiceProperties.action=\'_response/call.php?get=Operative/remittancefee.php\';
		subform(\'InvoiceProperties\',\'ORTax\');
		UnPopInvoice();');
?></td>
                    <td>Pagamento: </td>
                    <td>            <?php
                        $FieldQuery = "SELECT mp_ID AS ID, mp_ModoPago AS NAME
				FROM hd_modospago
				WHERE mp_ID = {$ORTYPEPAY}";
                        mn_field('select', $MDOR, 'FraModoPago', $ORTYPEPAY, $FieldQuery, '', 'True', '" readonly=" ');
?></td>
                </tr>
            </table></td>
    </tr>
</table>
</form>